var now = getNowFormatDateTime(); 
var username = sessionStorage.getItem("name");
var userid = sessionStorage.getItem("userId");
var searchtype =1;
var flag;
var trStr;
$(document).ready(function(){
	$("#username").prepend(username);
	$('#searchButton').on('click',function(){
		if($('#shopcode').val()== "" || $('#shopcode').val()==undefined){
			alert("门店编码不能为空")
		}else{
			$("#data").text('');
			getData();
		}
	});
});
function search(id){
	$("#shebei")[0].style.color="black";
	$("#jiankong")[0].style.color="black";
	if(id==1){
		$("#shebei")[0].style.color="red";
		$("#jiankongdiv")[0].style.display="none";
		$("#shebeidiv")[0].style.display="";
		$("#zhonglei")[0].style.display="none";
		searchtype = "1";
	}else{
		$("#jiankong")[0].style.color="red";
		$("#jiankongdiv")[0].style.display="";
		$("#shebeidiv")[0].style.display="none";
		$("#zhonglei")[0].style.display="none";
		searchtype = "2";
	}
	if($('#shopcode').val()!= "" && $('#shopcode').val()!=undefined){
		getData();
	}
}
function getData(){
	document.getElementById('data').innerHTML = "";
	$.ajax({
		url: '../../repair_info/equipment'
		,type:'post'
		,dataType:'json'
		,contentType: "application/json; charset=utf-8"
		,data:JSON.stringify({'shopcode':$('#shopcode').val(),"searchtable":searchtype,"falg":flag})  
		,success: function(res){
			console.log(res);
			if(res.data.length>0){
				$("#deptcode").html("");
				$("#deptname").html("");
				$("#deptcode").prepend(res.data[0].deptcode);
				$("#deptname").prepend(res.data[0].deptname);
				for (var i = 0; i < res.data.length; i++) {
					if(res.data[i].shopcode != "" && res.data[i].shopcode != undefined){
						trStr += '<tr class="thin-border-bottom">'
							+'	<td>'+res.data[i].equipment+'</span></td>'
							+'	<td>'+res.data[i].num+'</td>'
							+'	<td>'+res.data[i].buydate+'</td>'
							+'	<td>'+res.data[i].warranty+'</td>'
								+'</tr>'
					}
					
				}
			}

			$('#data').append(trStr);
			trStr ="";
		}
	});
}